/*
 * PathContext.java
 *
 * Created on July 26, 2007, 1:06 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package dnbW.uiW.dbW;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

/**
 *
 * @author zhouyong
 */
/**
 *  Atomic path context
 */
public final class PathContext {
    // <editor-fold desc="Schema Path">
    private TreePath schemaPath;
    public TreePath getSchemaPath() {
        return schemaPath;
    }

    protected void setSchemaPath(TreePath schemaPath) {
        this.schemaPath = schemaPath;
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) (schemaPath.getLastPathComponent());
        this.setContextNode(node);
    }
    // </editor-fold>

    // <editor-fold desc="Context Node">
    private DefaultMutableTreeNode contextNode;
    public DefaultMutableTreeNode getContextNode() {
        return contextNode;
    }

    protected void setContextNode(DefaultMutableTreeNode contextNode) {
        this.contextNode = contextNode;
    }
    // </editor-fold>

    // <editor-fold desc="Construction Time">
    /**
     * The time that the path context is created.
     */
    private final long constructionTime;

    public long getConstructionTime() {
        return constructionTime;
    }
    // </editor-fold>
    
    /** Creates a new instance of PathContext */
    protected PathContext() {
        this.constructionTime = System.currentTimeMillis();
    }

    public PathContext(TreePath schemaPath) {
        this();
        this.setSchemaPath(schemaPath);
    }

    @Override
    public String toString() {
        return this.getSchemaPath().toString();
    }
}
